{include file='../__header.tpl'}
{if $ed}
    <input type="hidden" value="{$pd.product_id}" id="pid" /> 
{/if}
<input type="hidden" value="{$mod}" id="mod" /> 
<input type="hidden" value="{$smarty.server.HTTP_REFERER}" id="http_referer" /> 
<i id="scriptTag">page_iframe_alter_product</i>
<form id="pd-baseinfo" style="padding-bottom: 55px;">
    <div style="padding-right: 22px;padding-top: 20px;" class="clearfix">
        <div style="float:left;width:70%;">
            <input id="pd-catimg" name="catimg" type="hidden" value="{$pd.catimg}" />
            <input id="pd-serial-val" type="hidden" value="{$pd.product_serial}" />
            <input id="pd-form-cat" type="hidden" value="{$cat}" />
            {foreach from=$pd.images item=pdi}
                <input class="pd-images" type="hidden" value="{$pdi.image_path}" />
            {/foreach}
            <div style="margin-left: 22px;">
                <div class="clearfix">

                    <!-- 商品名称 -->
                    <div style="float:left;width: 66%">
                        <div class="gs-label">商品名称</div>
                        <div class="gs-text">
                            <input type="text" name="product_name" value="{if $ed}{$pd.product_name}{/if}" id="pd-form-title" autofocus/>
                        </div>
                    </div>                    
                    <div style="float:left;width: 32%;margin-left: 2%;">

                        <!-- 商品分类 -->
                        <div class="gs-label">商品分类</div>
                        {strip}
                            <select id="pd-catselect" style="color:#000" name="product_cat" >
                                {foreach from=$categorys item=cat1}
                                    <option value="{$cat1.dataId}" {if $cat1.hasChildren}disabled{/if}>{$cat1.name}</option>
                                    {foreach from=$cat1.children item=cat2}
                                        <option value="{$cat2.dataId}" {if $cat2.hasChildren}disabled{/if}>-- {$cat2.name}</option>
                                        {foreach from=$cat2.children item=cat3}
                                            <option value="{$cat3.dataId}" {if $cat3.hasChildren}disabled{/if}>---- {$cat3.name}</option>
                                            {foreach from=$cat3.children item=cat4}
                                                <option value="{$cat4.dataId}" {if $cat4.hasChildren}disabled{/if}>------ {$cat4.name}</option>
                                            {/foreach}
                                        {/foreach}
                                    {/foreach}
                                {/foreach}
                            </select>
                        {/strip}

                    </div>
                </div>

                <div class="clearfix">

                    <!-- 商品价格 -->
                    <div style="float:left;width: 32%">
                        <div class="gs-label">商品价格</div>
                        <div class="gs-text">
                            <input type="text" onclick="this.select();" value="{if $ed}{$pd.sale_prices}{else}0.00{/if}" id="pd-form-prices" />
                        </div>
                    </div>

                    <!-- 商品折扣 -->
                    <div style="float:left;width: 32%;margin-left: 2%;">
                        <div class="gs-label">市场参考价</div>
                        <div class="gs-text">
                            <input type="hidden" id="pd-form-discount" value="{if $ed}{$pd.discount}{else}100{/if}"/>
                            <input type="text" name="market_price" onclick="this.select();" value="{if $ed and $pd.market_price}{$pd.market_price}{else}0.00{/if}" id="market_price" />
                        </div>
                    </div>

                    <!-- 商品品牌 -->
                    <div style="float:left;width: 32%;margin-left: 2%;">
                        <div class="gs-label">商品品牌</div>
                        <select id="pd-serial" name="product_brand">
                            <option value="0" {if $pd.product_brand eq 0}selected{/if}>默认</option>
                            {foreach from=$brands item=ser}
                                <option value="{$ser.id}" {if $pd.product_brand eq $ser.id}selected{/if}>{$ser.brand_name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>

                <div class="clearfix">

                    <!-- 商品编号 -->
                    <div style="float:left;width: 32%">
                        <div class="gs-label">商品编号</div>
                        <div class="gs-text">
                            <input type="text" name="product_code" onclick="this.select();" value="{if $ed}{$pd.product_code}{/if}" id="pd-form-code" />
                        </div>
                    </div>

                    <!-- 商品简称 -->
                    <div style="float:left;width: 32%;margin-left: 2%;">
                        <div class="gs-label">商品简称</div>
                        <div class="gs-text">
                            <input type="text" name="product_subname" id="pd-form-subname" value="{if $ed}{$pd.product_subname}{/if}"/>
                        </div>
                    </div>

                    <!-- 商品重量 -->
                    <div style="float:left;width: 32%;margin-left: 2%;">
                        <div class="gs-label">商品重量(g)</div>
                        <div class="gs-text">
                            <input type="text" name="product_weight" id="pd-form-weight" value="{if $ed > 0}{$pd.product_weight}{else}0{/if}"/>
                        </div>
                    </div>

                </div>

                <!-- 商品简介 -->
                <div class="gs-label">商品简介</div>
                <span class="frm_textarea_box"><textarea class="js_desc frm_textarea" id="pd-form-desc" name="product_subtitle">{if $ed}{$pd.product_subtitle}{/if}</textarea></span>

                <!-- 商品规格 -->
                <div class="gs-label">商品规格 
                    <a id='pd-spec-edit-btn' class="fancybox.ajax" data-fancybox-type="ajax" href="{$docroot}?/WdminPage/ajax_alter_product_spec_detail/id={$pd.product_id}">选择</a>
{*                    <a id='pd-spec-edit-btn-rep' class="fancybox.ajax" data-fancybox-type="ajax" href="{$docroot}?/WdminPage/ajax_alter_product_spec_rep/id={$pd.product_id}">快速添加</a>*}
                </div>
                
                <!-- 商品规格表 -->
                <table id='pd-spec-frame' style="margin-bottom:10px;{if $pd.specs|count eq 0}display:none;{/if}">
                    <thead>
                        <tr><th>规格</th><th>规格</th><th>价格</th><th>市场参考价</th></tr>
                    </thead>
                    <tbody>
                        {foreach from=$pd.specs item=specs}
                            <tr>
                                <td>{$specs.name1}</td>
                                <td>{$specs.name2}</td>
                                <td><input type="text" onclick="this.select();" class="pd-spec-prices" data-id="{$specs.id1}-{$specs.id2}" value="{$specs.sale_price}"></td>
                                <td><input type="text" onclick="this.select();" class="pd-spec-market" data-id="{$specs.id1}-{$specs.id2}" value="{$specs.market_price}"></td>
                            </tr>
                        {/foreach}
                    </tbody>
                </table>
            </div>
        </div>

        <!-- 商品大图 -->
        <div style="margin-left:69%;padding-left:30px;">
            <a class="pd-image-sec" data-id="0" href="javascript:;"></a>
        </div>
    </div>
    <div style="padding: 0px 22px;" class="clearfix">
        <div class="gs-label">商品图集</div>
        <div id="pd-ilist" class="clearfix">
            <a class="pd-image-sec ps20" data-id="1" href="javascript:;"></a>
            <a class="pd-image-sec ps20" data-id="2" href="javascript:;"></a>
            <a class="pd-image-sec ps20" data-id="3" href="javascript:;"></a>
            <a class="pd-image-sec ps20" data-id="4" href="javascript:;"></a>
            <a class="pd-image-sec ps20" data-id="5" href="javascript:;"></a>
        </div>
        <div class="gs-label">详细介绍</div>
        <script style='width:99.2%;' id="ueditorp" type="text/plain" name="product_desc">{if $ed}{$pd.product_desc}{/if}</script>
    </div>
</form>
<div class="fix_bottom fixed">
    <a id="save_product_btn"  href="javascript:;" class="wd-btn primary">保存</a>
    {if $mod ne 'add'}<a class="wd-btn delete pd-del-btn" data-product-id="{$pd.product_id}">删除</a>{/if}
    <a onclick="location.href = $('#http_referer').val();" class="wd-btn default">返回</a>
</div>
{include file='../__footer.tpl'} 